
package com.borqs.music.model;

import android.os.Parcel;
import android.os.Parcelable;

public class DownloadItem implements Parcelable {
    private int id;
    private String title;
    private String artist;
    private String fileName;
    private String fileMD5;
    private boolean isFavorite = false;

    public int status;
    public long value;
    public long max;

    public DownloadItem(int id, String title, String artist, String fileName, String fileMD5, boolean isFavorie) {
        this.id = id;
        this.title = title;
        this.artist = artist;
        this.fileName = fileName;
        this.fileMD5 = fileMD5;
        this.isFavorite = isFavorie;
    }

    public int getId() {
        return id;
    }

    public String getTitle() {
        return title;
    }

    public String getArtist() {
        return artist;
    }

    public String getFileName() {
        return fileName;
    }

    public String getFileMD5() {
        return fileMD5;
    }

    public boolean isFavorite() {
        return isFavorite;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof DownloadItem)) {
            return false;
        }
        DownloadItem item = (DownloadItem) o;
        if (id == item.getId()) {
            return true;
        }
        return false;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Parcelable.Creator<DownloadItem> CREATOR = new Parcelable.Creator<DownloadItem>() {

        public DownloadItem createFromParcel(Parcel in) {
            return new DownloadItem(in);
        }

        public DownloadItem[] newArray(int size) {
            return new DownloadItem[size];
        }

    };

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(id);
        dest.writeString(title);
        dest.writeString(artist);
        dest.writeString(fileName);
        dest.writeString(fileMD5);
        dest.writeInt(isFavorite ? 1 : 0);
        dest.writeInt(status);
        dest.writeLong(value);
        dest.writeLong(max);
    }

    private DownloadItem(Parcel in) {
        id = in.readInt();
        title = in.readString();
        artist = in.readString();
        fileName = in.readString();
        fileMD5 = in.readString();
        isFavorite = in.readInt()==1;
        status = in.readInt();
        value = in.readLong();
        max = in.readLong();
    }
}
